package cn.com.hp.feature.service.impl;

import cn.com.hp.feature.domain.dto.OrderInfoDTO;
import cn.com.hp.feature.domain.entity.MenuInfo;
import cn.com.hp.feature.domain.entity.OrderInfo;
import cn.com.hp.feature.domain.vo.PageVO;
import cn.com.hp.feature.mapper.MenuInfoMapper;
import cn.com.hp.feature.mapper.OrderInfoMapper;
import cn.com.hp.feature.service.IMenuInfoService;
import cn.com.hp.feature.service.IOrderInfoService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: hjz
 * @since: 2022/9/1
 * @description:
 */
@Service
public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo> implements IOrderInfoService {

    @Autowired
    private OrderInfoMapper orderInfoMapper;

    @Override
    public PageVO<OrderInfo> selectOderPage(OrderInfoDTO orderInfoDTO) {
        PageVO<OrderInfo> data = new PageVO();

        //默认分页数据是第一页，每页10条
        int current = orderInfoDTO.getPage() == null ? 1 : orderInfoDTO.getPage();
        int size = orderInfoDTO.getRow() == null ? 10 : orderInfoDTO.getRow();
        Page<OrderInfo> page = new Page<>(current, size);
        //获取分页数据
        Page<OrderInfo> pages = orderInfoMapper.selectOderPage(page, orderInfoDTO);
        data.setList(pages.getRecords());
        data.setPage(pages.getCurrent());
        data.setPageSize(pages.getSize());
        data.setTotal(pages.getTotal());
        return data;
    }
}
